package com.example.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.common.annotation.Log;
import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.AjaxResult;
import com.example.common.enums.BusinessType;
import com.example.business.domain.TableInfo;
import com.example.business.service.ITableInfoService;
import com.example.common.utils.poi.ExcelUtil;
import com.example.common.core.page.TableDataInfo;

/**
 * 薪资管理Controller
 * 
 * @author Zhf
 * @date 2025-01-18
 */
@RestController
@RequestMapping("/business/TableInfo")
public class TableInfoController extends BaseController
{
    @Autowired
    private ITableInfoService tableInfoService;

    /**
     * 查询薪资管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:TableInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TableInfo tableInfo)
    {
        startPage();
        List<TableInfo> list = tableInfoService.selectTableInfoList(tableInfo);
        return getDataTable(list);
    }

    /**
     * 导出薪资管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:TableInfo:export')")
    @Log(title = "薪资管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TableInfo tableInfo)
    {
        List<TableInfo> list = tableInfoService.selectTableInfoList(tableInfo);
        ExcelUtil<TableInfo> util = new ExcelUtil<TableInfo>(TableInfo.class);
        util.exportExcel(response, list, "薪资管理数据");
    }

    /**
     * 获取薪资管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:TableInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tableInfoService.selectTableInfoById(id));
    }

    /**
     * 新增薪资管理
     */
    @PreAuthorize("@ss.hasPermi('business:TableInfo:add')")
    @Log(title = "薪资管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TableInfo tableInfo)
    {
        return toAjax(tableInfoService.insertTableInfo(tableInfo));
    }

    /**
     * 修改薪资管理
     */
    @PreAuthorize("@ss.hasPermi('business:TableInfo:edit')")
    @Log(title = "薪资管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TableInfo tableInfo)
    {
        return toAjax(tableInfoService.updateTableInfo(tableInfo));
    }

    /**
     * 删除薪资管理
     */
    @PreAuthorize("@ss.hasPermi('business:TableInfo:remove')")
    @Log(title = "薪资管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tableInfoService.deleteTableInfoByIds(ids));
    }
}
